<template>
  <div class="header">
    <div class="header-content">
      <!-- Logo区域 -->
      <div class="logo-container">
        <div class="logo">
          <span class="logo-text">YOYO</span>
          <span class="logo-icon">
            <i class="el-icon-reading"></i>
          </span>
        </div>
        <div class="slogan">悠悠般的沉浸式学习氛围</div>
      </div>

      <!-- 导航菜单 -->
      <div class="nav-menu">
        <div 
          v-for="item in navItems" 
          :key="item.path"
          class="nav-item"
          :class="{ active: isActive(item.path) }"
          @click="$router.push(item.path)"
        >
          {{ item.name }}
        </div>
      </div>

      <!-- 用户操作区 -->
      <div class="user-actions">
        <el-button type="text" @click="$router.push('/login')">登录</el-button>
        <el-button type="primary" @click="$router.push('/register')">注册</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CommonHeader',
  data() {
    return {
      navItems: [
        { name: '首页', path: '/' },
        { name: '自习室', path: '/rooms' },
        { name: '失物招领', path: '/lost-found' },
        { name: '论坛', path: '/forum' }
      ]
    }
  },
  methods: {
    isActive(path) {
      return this.$route.path === path || 
        (path === '/rooms' && this.$route.path.startsWith('/room/'))
    }
  }
}
</script>

<style scoped>
.header {
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
  margin-bottom: 0;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-text {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(45deg, #409EFF, #67C23A);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 2px;
  font-family: 'Poppins', sans-serif;
}

.logo-icon {
  font-size: 28px;
  color: #409EFF;
  animation: float 3s ease-in-out infinite;
}

.slogan {
  font-size: 14px;
  color: #909399;
  margin-top: 4px;
  letter-spacing: 1px;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.nav-menu {
  display: flex;
  gap: 30px;
}

.nav-item {
  font-size: 16px;
  color: #606266;
  cursor: pointer;
  padding: 5px 0;
  position: relative;
  transition: all 0.3s;
}

.nav-item:hover {
  color: #409EFF;
}

.nav-item.active {
  color: #409EFF;
}

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: #409EFF;
  border-radius: 1px;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

@media (max-width: 768px) {
  .logo-desc {
    display: none;
  }

  .nav-menu {
    gap: 15px;
  }

  .nav-item {
    font-size: 14px;
  }
}
</style> 